import 'rc_status_define.dart';
import 'message_content.dart';
import 'dart:convert' show json;

class FileMessage extends MessageContent {
  static const String objectName = "RC:FileMsg";

  String extra;
  String fileUrl;
  String name;
  int size;
  String type;
  Map user;

  @override
  void decode(String jsonStr) {
    Map map = json.decode(jsonStr.toString());
    this.extra = map["extra"];
    this.fileUrl = map["fileUrl"];
    this.name = map["name"];
    this.size = map["size"];
    this.type = map["type"];
    this.user = map["user"];
  }

  @override
  String encode() {
    Map map = {
      "extra": this.extra,
      "fileUrl": this.fileUrl,
      "name": this.name,
      "size": this.size,
      "type": this.type,
      "user": this.user,
    };
    return json.encode(map);
  }

  @override
  String conversationDigest() {
    return "图片";
  }

  @override
  String getObjectName() {
    return objectName;
  }

  static int persistentFlag() {
    return RCMessagePersistentFlag.IsPersisted |
        RCMessagePersistentFlag.IsCounted;
  }
}
